#include "canbus/message.h"
#include "canbus/consts.h"

/**
 * @namespace canbus
 * @brief canbus
 */
namespace canbus {

/**
 * @class CanMsg12
 * @brief Concrete can message that stores spreader state information
 */
class CanMsg12: public CanMsg {
public:
  CanMsg12():
  CanMsg(),
  hoist_height(kHoistHeightDefault),
  front_sprd_pos(kHydraulicDefault),
  back_sprd_pos(kHydraulicDefault)
  {}

  CanMsg12(uint8_t* value): 
  CanMsg(value), 
  hoist_height(kHoistHeightDefault),
  front_sprd_pos(kHydraulicDefault),
  back_sprd_pos(kHydraulicDefault)
  {}

  virtual ~CanMsg12() = default;

  void UpUpdateData() {
    hoist_height =   ParseTwins(*(data_+1), *(data_+0));
    front_sprd_pos = ParseTwins(*(data_+3), *(data_+2));
    back_sprd_pos =  ParseTwins(*(data_+5), *(data_+4));
  }

  template <typename T>
  void DownUpdateData(const T& input_data) {}

  static const int32_t ID;
  static const std::string NAME;

  uint16_t hoist_height;
  uint16_t front_sprd_pos;
  uint16_t back_sprd_pos;

  friend class CanbusHandler;
};

}